      SUBROUTINE BCDTOINT (INPUT1, INPUT2, OUTPUT)
C
C *****************************************************************************
C     SUBROUTINE TO CONVERT GOES/GVAR "BCD TIME" INTO TIME VALUE WHICH NOAA'S
C     "GIMLOC" SOFTWARE REQUIRES.
C  
C     ORIGINAL:	BRUCE H. THOMAS, THE AEROSPACE CORPORATION
C		DEFENSE METEOROLOGICAL SATELLITE PROGRAM (DMSP)
C		ENVIRONMENTAL APPLICATIONS CENTER, MARCH 1997
C
C     NOTE:     THE SECOND HALF OF THE "BCD" DATE/TIME (OADATA(13)) IS EMPTY!!!
C		GOES/GVAR SPEC INDICATES HOURS IN 1'S, MIN, SEC, MILLI SEC
C		SHOULD BE PRESENT.  WORK LATER IF REQUIRED!!! 
C *****************************************************************************
C
      IMPLICIT NONE
C
      LOGICAL PRINT_FLAG
      INTEGER IY1000,IY100,IY10,IY1,IDOY100,IDOY10,IDOY1,IHR10
      INTEGER INPUT1,INPUT2,IBYTE1,IBYTE2,IBYTE3,IBYTE4,IHB1,IHB2
      INTEGER IYEAR,IDAY,IHOUR,IHR1
      REAL*8 OUTPUT
C
      DATA PRINT_FLAG / .FALSE. /
C
      IBYTE1 = IBITS(INPUT1,00,8)
      IHR10 = IBITS(IBYTE1,0,4)
      IDOY1 = IBITS(IBYTE1,4,4)
C
      IBYTE2 = IBITS(INPUT1,08,8)
      IDOY10 = IBITS(IBYTE2,0,4)
      IDOY100 = IBITS(IBYTE2,4,4)
C
      IBYTE3 = IBITS(INPUT1,16,8)
      IY1 = IBITS(IBYTE3,0,4)
      IY10 = IBITS(IBYTE3,4,4)
C
      IBYTE4 = IBITS(INPUT1,24,8)
      IY100 = IBITS(IBYTE4,0,4)
      IY1000 = IBITS(IBYTE4,4,4)
C
      IYEAR = IY1000 * 1000 + IY100 * 100 + IY10 * 10 + IY1
      IDAY = IDOY100 * 100 + IDOY10 * 10 + IDOY1
      IHOUR = IHR10 * 10 + IHR1
C
      IF (PRINT_FLAG) THEN
        PRINT *,'BCD_TO_INT: YEAR = ',IYEAR
        PRINT *,'BCD_TO_INT: DAY OF YEAR = ',IDAY
        PRINT *,'BCD_TO_INT: HOUR OF DAY = ',IHOUR
      ENDIF
C
      IBYTE1 = IBITS(INPUT2,00,8)
      IHB1 = IBITS(IBYTE1,0,4)
      IHB2 = IBITS(IBYTE1,4,4)
C
      IF (PRINT_FLAG) THEN
        PRINT *,'BCD_TO_INT: OADATA(13) INFORMATION.... '
        PRINT *,'BCD_TO_INT: INPUT2 BYTE 1 = ',IBYTE1
        PRINT *,'BCD_TO_INT: HALF BYTE 1 = ',IHB1
        PRINT *,'BCD_TO_INT: HALF BYTE 2 = ',IHB2
      ENDIF
C
      IBYTE2 = IBITS(INPUT2,08,8)
      IHB1 = IBITS(IBYTE2,0,4)
      IHB2 = IBITS(IBYTE2,4,4)
C
      IF (PRINT_FLAG) THEN
        PRINT *,'BCD_TO_INT: INPUT2 BYTE 2 = ',IBYTE2
        PRINT *,'BCD_TO_INT: HALF BYTE 1 = ',IHB1
        PRINT *,'BCD_TO_INT: HALF BYTE 2 = ',IHB2
      ENDIF
C
      IBYTE3 = IBITS(INPUT2,16,8)
      IHB1 = IBITS(IBYTE3,0,4)
      IHB2 = IBITS(IBYTE3,4,4)
C
      IF (PRINT_FLAG) THEN
        PRINT *,'BCD_TO_INT: HALF BYTE 1 = ',IHB1
        PRINT *,'BCD_TO_INT: HALF BYTE 2 = ',IHB2
        PRINT *,'BCD_TO_INT: INPUT2 BYTE 3 = ',IBYTE3
      ENDIF
C
      IBYTE4 = IBITS(INPUT2,24,8)
      IHB1 = IBITS(IBYTE4,0,4)
      IHB2 = IBITS(IBYTE4,4,4)
C
      IF (PRINT_FLAG) THEN
        PRINT *,'BCD_TO_INT: INPUT2 BYTE 4 = ',IBYTE4
        PRINT *,'BCD_TO_INT: HALF BYTE 1 = ',IHB1
        PRINT *,'BCD_TO_INT: HALF BYTE 2 = ',IHB2
      ENDIF
C
      RETURN
      END
